﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using DDD_AOP_WCF.Domain;
using Domain.Core.Specification;

namespace DDD_AOP_WCF.Domain.Products
{
    /// <summary>
    /// 通过用户信息得到他的订单列表
    /// </summary>
    public class ProductSpecification : Specification<Product>
    {
        string _productName = default(string);
        public ProductSpecification(string productName)
        {
            _productName = productName;
        }
        public override Expression<Func<Product, bool>> SatisfiedBy()
        {
            Specification<Product> spec = new TrueSpecification<Product>();
            if (string.IsNullOrWhiteSpace(_productName))
                spec &= new DirectSpecification<Product>(o => o.ProductName.Contains(_productName));
            return spec.SatisfiedBy();
        }
    }
}
